package cn.edu.zafu.bigdata.x.bd121.shape;

/**
 * final 测试demo
 *
 * @author 202211090121
 */
public abstract class Shape {

    /**
     * 计算面积
     *
     * @return 面积
     */
    public abstract double area();

    /**
     * 计算周长
     *
     * @return 周长
     */
    public abstract double perimeter();

    /**
     * 输出结果信息
     */
    public final void display() {
        // 获取当前的类名，用于下文形状的输出
        String type = this.getClass().getSimpleName();
        double area = this.area();
        double perimeter = this.perimeter();
        System.out.printf("当前形状:%s,面积:%f,周长:%f\n", type, area, perimeter);
    }
}
